Micron Document
🎖️GitЯра🎖️

Node / meshtastic / Meshtastic-Android / files / core / barcode / src / fdroid / kotlin / org / meshtastic / core / barcode / BarcodeAnalyzerFactory.kt

Displaying Raw • Download

core/barcode/src/fdroid/kotlin/org/meshtastic/core/barcode/BarcodeAnalyzerFactory.kt 0a44b948ec0573dc62ec68c19e46e62d40fcd1a3 (0a44b948) Text, 2.03 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.barcode

Tff7b72import T7ee787androidx.camera.core.ImageAnalysis
Tff7b72import T7ee787com.google.zxing.BinaryBitmap
Tff7b72import T7ee787com.google.zxing.MultiFormatReader
Tff7b72import T7ee787com.google.zxing.PlanarYUVLuminanceSource
Tff7b72import T7ee787com.google.zxing.common.HybridBinarizer
Tff7b72import T7ee787java.nio.ByteBuffer

T8b949e/**
* Creates a CameraX [ImageAnalysis.Analyzer] that decodes QR codes using ZXing.
*
* This is the F-Droid flavor implementation; the Google flavor uses ML Kit instead.
*/
Tff7b72internal Tff7b72fun Td2a8ffcreateBarcodeAnalyzerTb4b4b4(Te6edf3onResultTb4b4b4: Tb4b4b4(Tffa657StringTb4b4b4) Tff7b72-Tff7b72> Tffa657UnitTb4b4b4)Tb4b4b4: Te6edf3ImageAnalysisTb4b4b4.Te6edf3Analyzer Tb4b4b4{
Tff7b72val Te6edf3reader Tff7b72= Te6edf3MultiFormatReaderTb4b4b4(Tb4b4b4)

Tff7b72return Te6edf3ImageAnalysisTb4b4b4.Te6edf3Analyzer Tb4b4b4{ Te6edf3imageProxy Tff7b72-Tff7b72>
Tff7b72try Tb4b4b4{
Tff7b72val Te6edf3bufferTb4b4b4: Te6edf3ByteBuffer Tff7b72= Te6edf3imageProxyTb4b4b4.Te6edf3planesTff7b72[T79c0ff0Tff7b72]Tb4b4b4.Te6edf3buffer
Tff7b72val Te6edf3data Tff7b72= Te6edf3ByteArrayTb4b4b4(Te6edf3bufferTb4b4b4.Te6edf3remainingTb4b4b4(Tb4b4b4)Tb4b4b4)
Te6edf3bufferTb4b4b4.Te6edf3getTb4b4b4(Te6edf3dataTb4b4b4)

Tff7b72val Te6edf3width Tff7b72= Te6edf3imageProxyTb4b4b4.Te6edf3width
Tff7b72val Te6edf3height Tff7b72= Te6edf3imageProxyTb4b4b4.Te6edf3height

Tff7b72val Te6edf3source Tff7b72= Te6edf3PlanarYUVLuminanceSourceTb4b4b4(Te6edf3dataTb4b4b4, Te6edf3widthTb4b4b4, Te6edf3heightTb4b4b4, T79c0ff0Tb4b4b4, T79c0ff0Tb4b4b4, Te6edf3widthTb4b4b4, Te6edf3heightTb4b4b4, Tff7b72falseTb4b4b4)
Tff7b72val Te6edf3binaryBitmap Tff7b72= Te6edf3BinaryBitmapTb4b4b4(Te6edf3HybridBinarizerTb4b4b4(Te6edf3sourceTb4b4b4)Tb4b4b4)

Tff7b72val Te6edf3result Tff7b72= Te6edf3readerTb4b4b4.Te6edf3decodeWithStateTb4b4b4(Te6edf3binaryBitmapTb4b4b4)
Te6edf3resultTb4b4b4.Te6edf3textTff7b72?.Te6edf3let Tb4b4b4{ Te6edf3onResultTb4b4b4(Tffa657itTb4b4b4) Tb4b4b4}
Tb4b4b4} Tff7b72catch Tb4b4b4(Te6edf3_Tb4b4b4: Te6edf3ExceptionTb4b4b4) Tb4b4b4{
T8b949e// Ignore decoding errors — no barcode found in this frame
Tb4b4b4} Tff7b72finally Tb4b4b4{
Te6edf3imageProxyTb4b4b4.Te6edf3closeTb4b4b4(Tb4b4b4)
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.13s